package com.mfcxy.entity;

import java.util.ArrayList;
import java.util.List;

import org.springframework.format.number.CurrencyStyleFormatter;

import com.mfcxy.exception.CustomException;

/**
 * 分类实体类
 * 
 * @author mfcxy
 *
 */
public class Type {
	private int id;
	private String name;
	private String image = "";
	private int pid;
	private String path;
	private String open;
	private int level;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getPid() {
		return pid;
	}

	public void setPid(int pid) {
		this.pid = pid;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public String getOpen() {
		return open;
	}

	public void setOpen(String open) {
		this.open = open;
	}

	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		this.level = level;
	}

	public String getImage() {
		return image;
	}

	public void setImage(String image) {
		this.image = image;
	}
	
	/**
	 * 新增分类数据效验
	 * @throws CustomException
	 */
	public void checkAdd() throws CustomException {
		List<String> msglist = new ArrayList<>();
		if(name == null || name.trim().equals("")) {
			msglist.add("分类名称不能为空");
		}
		
		if(path == null || path.trim().equals("")) {
			msglist.add("父级路径不能为空");
		}
		
		if(msglist.size() > 0) {
			throw new CustomException(msglist.toString());
		}
	}

	@Override
	public String toString() {
		return "TypeController [id=" + id + ", name=" + name + ", image=" + image + ", pid=" + pid + ", path=" + path + ", open="
				+ open + ", level=" + level + "]";
	}
	
	

}
